package com.atguigu.tingshu.account.config;

import com.atguigu.tingshu.common.constant.TingShuMqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AccountMqConfig {

    @Bean
    public Queue ttlQueue(){
        return QueueBuilder.durable(TingShuMqConstants.ACCOUNT_TTL_QUEUE)
                .ttl(TingShuMqConstants.ACCOUNT_TTL_TIME)
                .deadLetterExchange(TingShuMqConstants.ORDER_EXCHANGE)
                .deadLetterRoutingKey(TingShuMqConstants.ACCOUNT_DEAD_RK)
                .build();
    }
    @Bean
    public Binding ttlBinding(){
        return new Binding(TingShuMqConstants.ACCOUNT_TTL_QUEUE,Binding.DestinationType.QUEUE,
                TingShuMqConstants.ORDER_EXCHANGE,TingShuMqConstants.ACCOUNT_TTL_RK,null);
    }
}
